/**
 * @author 陈泰来
 * @version V1.0
 * @Project echo-java-base
 * @Title 自定义天气布告板
 * @Description *
 * @Package designmodel.observe.watcher.concret
 * @date 2020/10/25 7:54 下午
 * @Copyright:学如逆水行舟，不进则退 .
 */
package designmodel.observe.watcher.concret;

import designmodel.observe.theme.OutsideData;
import designmodel.observe.watcher.Display;
import designmodel.observe.watcher.Observer;

public class ConcretConditionDisplayBoard implements Display, Observer {
    private float temperature;
    private float pressure;
    private final String name;
    private final OutsideData weatherData;

    public ConcretConditionDisplayBoard(OutsideData weatherData) {
        this.name = "自定义布告板";
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println("我是:[" + name + "]当前气温：" + temperature + "F 当前压力值:" + pressure + "Pa");
    }

    @Override
    public void update(float t, float h, float p) {
        this.pressure = p;
        this.temperature = t;
        display();
    }
}
